package com.example.tnot.Teacher.Homepart.InternalFragment.Frequent.Agent.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Publish.ItemBean.ListCourse;

import java.util.List;

public class rvAgent extends RecyclerView.Adapter<rvAgent.ViewHolder> {
    private List<ListCourse> list;
    public rvAgent(List<ListCourse> list) {
        this.list = list;
    }
    @NonNull
    @Override
    public rvAgent.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_publish_home_course_itemlist, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull rvAgent.ViewHolder holder, int position) {
        ListCourse listCourse = list.get(position);
        holder.tv_class.setVisibility(View.VISIBLE);
        holder.tv_status.setVisibility(View.VISIBLE);
        holder.tv_Teacher.setVisibility(View.GONE);

        holder.iv_icon.setImageResource(listCourse.getIv_icon());
        holder.tv_title.setText(listCourse.getTv_title());
        holder.tv_Time.setText(listCourse.getIv_Time());
        holder.tv_status.setText(listCourse.getStatus());
        holder.tv_class.setText(listCourse.getClassName());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView iv_icon;
        TextView tv_Teacher,tv_status,tv_title,tv_Time,tv_class;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tv_status = itemView.findViewById(R.id.tv_status);
            iv_icon = itemView.findViewById(R.id.iv_icon);
            tv_Time = itemView.findViewById(R.id.tv_time);
            tv_title = itemView.findViewById(R.id.tv_title);
            tv_Teacher = itemView.findViewById(R.id.tv_teacher);
            tv_class = itemView.findViewById(R.id.tv_class);
        }
    }
}
